package com.epigeon.amadeo.test;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.util.AttributeSet;

import com.epigeon.amadeo.impl.ActiveButton;
import com.epigeon.amadeo.impl.XMPPConnectionInput;
import com.epigeon.amadeo.model.Message;
import com.epigeon.amadeo.model.StringMessage;
import com.epigeon.amadeo.model.XMPPMessage;

public class ActiveSendButton extends ActiveButton {

	public ActiveSendButton(Context context, AttributeSet attr) {
		super(context, attr);
	}

	@Override
	public Message compose(List<Message> messages) {
		String textMessage = null;
		String recipient = null;

		for (Message message : messages) {
			StringMessage sMessage = (StringMessage) message;
			String key = sMessage.getSourceKey();
			String value = sMessage.getValue();
			
			if ( XMPPDemo.TAG_TEXT_MESSAGE.equals(key) ) {
				textMessage = value;
			} else if ( XMPPDemo.TAG_TEXT_RECIPIENT.equals(key) ) {
				recipient = value;
			}
			
		}
		
		return new XMPPMessage(XMPPConnectionInput.MESSAGE_TYPE_SEND, this.getKey(), "Me", recipient, textMessage);
	}

	@Override
	public void setParameters(Map<String, String> parameterMap) {
		// TODO Auto-generated method stub
		
	}

}
